import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Params, Router} from '@angular/router';

@Component({
  selector: 'app-student-form',
  templateUrl: './student-form.component.html',
  styleUrls: ['./student-form.component.css']
})
export class StudentFormComponent implements OnInit {
  private studentId: number;
  private title: string;

  constructor(private routeInfo: ActivatedRoute, private router: Router) { }

  ngOnInit() {
    // this.studentId = this.routeInfo.snapshot.params['studentId'];
    this.routeInfo.params.subscribe((params: Params) => {
      this.studentId = params['studentId'];
      if (this.studentId == 0) {
        this.title = '添加学生信息';
      } else {
        this.title = '编辑学生信息';
      }
    });
  }

  cancel() {
    this.router.navigateByUrl('/studentManager');
  }
  confirm() {
    this.router.navigateByUrl('/studentManager');
  }

}
